﻿package view.popup
{
    import com.core.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.external.*;
    import flash.geom.*;
    import morn.core.components.*;
    import view.uilt.*;

    public class YbDialog extends View implements IDialogUI
    {
        public var closeBtn:Button;
        public var btn:Button;
        public var btn2:Button;
        public var text1:Label;
        public var text2:Label;
        protected var uiXML:XML;

        public function YbDialog()
        {
            this.uiXML = <View>r
n	t	t	t  <FlashS9Bg skin=""png.common.ms9"" x=""0"" y=""0"" width=""330"" height=""234""/>r
n	t	t	t  <Label text=""9"" x=""41"" y=""63"" color=""0xb29a6c"" stroke=""1"" align=""center"" width=""280"" size=""14"" height=""25"" var=""text1"" isHtml=""true"" font=""宋体""/>r
n	t	t	t  <Label text=""9"" x=""31"" y=""100"" color=""0x00ff00"" stroke=""1"" align=""center"" width=""280"" size=""14"" height=""25"" var=""text2"" font=""宋体""/>r
n	t	t	t  <Button skin=""png.common.btn_usual_normal"" x=""65"" y=""150"" var=""btn"" labelStroke=""1""/>  r
n	t	t	t  <Button skin=""png.common.btn_usual_normal"" x=""165"" y=""150"" var=""btn2"" labelStroke=""1""/>  	t	t	t r
n	t	t	t  <Button skin=""png.common.btn_close_normal"" x=""304"" y=""0"" var=""closeBtn""/>r
n	t	t	t</View>")("<View>
			  <FlashS9Bg skin="png.common.ms9" x="0" y="0" width="330" height="234"/>
			  <Label text="9" x="41" y="63" color="0xb29a6c" stroke="1" align="center" width="280" size="14" height="25" var="text1" isHtml="true" font="宋体"/>
			  <Label text="9" x="31" y="100" color="0x00ff00" stroke="1" align="center" width="280" size="14" height="25" var="text2" font="宋体"/>
			  <Button skin="png.common.btn_usual_normal" x="65" y="150" var="btn" labelStroke="1"/>  
			  <Button skin="png.common.btn_usual_normal" x="165" y="150" var="btn2" labelStroke="1"/>  			 
			  <Button skin="png.common.btn_close_normal" x="304" y="0" var="closeBtn"/>
			</View>;
            return;
        }// end function

        override protected function createChildren() : void
        {
            createView(this.uiXML);
            this.init();
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            return;
        }// end function

        public function init() : void
        {
            this.visible = false;
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            this.btn.label = "充值";
            this.btn.labelColors = "0xb29a6c, 0xb29a6c, 0xb29a6c";
            this.btn.addEventListener(MouseEvent.CLICK, this.onChongzhi);
            this.btn2.label = "确定";
            this.btn2.labelColors = "0xb29a6c, 0xb29a6c, 0xb29a6c";
            this.btn2.addEventListener(MouseEvent.CLICK, this.onSure);
            this.closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            GlobalLayer.instance.root.stage.addEventListener(Event.RESIZE, this.resizeHandler);
            return;
        }// end function

        private function onChongzhi(event:MouseEvent) : void
        {
            if (!ItemUilt.canpay)
            {
                ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                return;
            }
            ExternalInterface.call("topay");
            return;
        }// end function

        private function onSure(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function show(param1:Object) : void
        {
            this.visible = true;
            this.text1.text = "您还差  " + MColor.getHMTL(int(param1) + " 元宝", 5) + " 才能购买该物品";
            this.text2.text = "请您先充值在购买";
            return;
        }// end function

        private function onClose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function close() : void
        {
            this.visible = false;
            return;
        }// end function

        private function resizeHandler(event:Event) : void
        {
            this.x = GlobalLayer.instance.root.stage.stageWidth - this.width >> 1;
            this.y = GlobalLayer.instance.root.stage.stageHeight - this.height >> 1;
            var _loc_2:* = this.btn.localToGlobal(new Point(0, 0));
            ModelProxy.change("data", "itempoint", _loc_2);
            return;
        }// end function

    }
}
